﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace CRC.Formularios
{
    public partial class EstablecerFechaInspeccionPeriodica : Form
    {

        private int? intAño = null;
        private int? intMes = null;

        /*
         * Contructor 
        */
        public EstablecerFechaInspeccionPeriodica()
        {
            InitializeComponent();
        }
        /*
         *Constructor 
        */
        public EstablecerFechaInspeccionPeriodica(String pStrNombreSalon)
        {
            InitializeComponent();
            this.lblTextInformatiu.Text = String.Format(this.lblTextInformatiu.Text, pStrNombreSalon);
            CargarAñosYMeses();
        }

        private void CargarAñosYMeses() {
            for (int i = 2008; i < 2050; i++) {
                this.cmbAño.Items.Add(i);
            }

            for (int i = 1; i <= 12; i++) {
                this.cmbMes.Items.Add(i);
            }
        }

        private void cmbMes_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbMes.SelectedIndex != -1) this.intMes = (int?)cmbMes.SelectedItem;
            butOK.Enabled = (cmbAño.SelectedIndex != -1) && (cmbMes.SelectedIndex != -1);
        }

        private void cmbAño_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (cmbAño.SelectedIndex != -1) this.intAño = (int?)cmbAño.SelectedItem;
            butOK.Enabled = (cmbAño.SelectedIndex != -1) && (cmbMes.SelectedIndex != -1);
        }

        public int? Año
        {
            get { return this.intAño; }
            set { this.intAño = value; }
        }

        public int? Mes 
        {
            get { return this.intMes; }
            set { this.intMes = value; }
        }

        private void butOK_Click(object sender, EventArgs e)
        {
            this.Dispose();
        }
    }
}
